package com.rhit.rosehack.engine;

import java.awt.Color;

import com.rhit.rosehack.SQLObjects.Chunk;
import com.rhit.rosehack.SQLObjects.Creature;
import com.rhit.rosehack.SQLObjects.Query;


//This represents a monster creature.
public class Mob extends Creature {
	
	private Color myColor;
	
	public Mob()
	{
		this.setSymbol( 'a' );
		this.myColor = Color.white;
		this.setHP(10);
		this.setAttack(1);
		this.setDefense(1);
		this.setName("Monster");
	}
	
	public Mob(int x, int y, int chunkID, int floor) 
	{
		this();
		this.setAttack(((int)((Math.random()*5) + 1)) * (floor +1));
		this.setHP(((int)((Math.random()*10) + 1)) * (floor+1));
		this.setDefense(((int)((Math.random()*5) + 1)) * (floor+1));
		this.setX(x);
		this.setY(y);
		
		Query q = new Query();
		this.setCreatureID((q.genCreature(this.getName(), this.getLevel(), this.getHP(), this.getMP(), this.getAttack(),this.getDefense(), this.getMagic(), this.getType(), x,y,chunkID)));
	}
	
	public void setSymbol( char c )
	{
		this.setType( c );
	}

	public char getSymbol()
	{
		return ( char )this.getType();
	}
	
	public Color getColor()
	{
		return this.myColor;
	}

	public void takeTurn(Chunk floorData, int x, int y) 
	{
		//boolean tookMove = false;

		//while (!tookMove) 
		{
			int xRand = (int) (Math.random() * 3) - 1;
			int yRand = (int) (Math.random() * 3) - 1;
			
			if (!(this.getX() + xRand == x && this.getY() + yRand == y)
					&& floorData.getMap()[this.getY() + yRand][this.getX()
							+ xRand] != '#' && !floorData.monsAt(xRand,yRand)) 
			{
				this.setX(this.getX() + xRand);
				this.setY(this.getY() + yRand);
			//	tookMove = true;
			}
		}
	}

	@Override
	public void checkLevel() {
		// TODO Auto-generated method stub
		
	}
}
